import Mock from 'mockjs';

Mock.setup({
    timeout: '200-600'
});
const reconciliationMaterials = Mock.mock(/reconciliation-materials/, 'post', (options) => {
    var opts = JSON.parse(options.body);
    return Mock.mock({
        "code": "0000",
        "message": "操作失败",
        "data": {
            "data": []
        }
    })
    console.log(opts);
    if (opts.per_page === 10) {
        return Mock.mock({
            "code": "0000",
            "message": "操作成功",
            "data": {
                "data|10": [{
                    "id|+1": 10,
                    "payee_source_no": "QS201805310003",
                    "signed_date": "2018-05-31",
                    "payer_id": 12,
                    "payer_name": "重庆强兵实业有限公司",
                    "category_id": 22,
                    "category_name": "钢材",
                    "material_id": 15,
                    "material_info": {
                        'name': '角钢1号',
                        'model': '8分',
                        'code': '33683',
                        'customer_attr': {
                            'attr_1': 'value_1',
                            'attr_2': 'value_2'
                        }
                    },
                    "brand": "重钢",
                    "price": 1000.88,
                    "quantity": 500.25,
                    "unit": "吨",
                    "is_taxed": 1,
                    "tax_rate": 17
                }],
                "total": 20,
                "current_page": opts.page,
                "per_page": opts.per_page
            }
        })
    } else if (opts.per_page === 20) {
        return Mock.mock({
            "code": "0000",
            "message": "操作成功",
            "data": {
                "data|20": [{
                    "id|+1": 50,
                    "payee_source_no": "QS201805310003",
                    "signed_date": "2018-05-31",
                    "payer_id": 12,
                    "payer_name": "重庆强兵实业有限公司",
                    "category_id": 22,
                    "category_name": "钢材",
                    "material_id": 15,
                    "material_info": {
                        'name': '角钢1号',
                        'model': '8分',
                        'code': '33683',
                        'customer_attr': {
                            'attr_1': 'value_1',
                            'attr_2': 'value_2'
                        }
                    },
                    "brand": "重钢",
                    "price": 1000.88,
                    "quantity": 500.25,
                    "unit": "吨",
                    "is_taxed": 1,
                    "tax_rate": 17
                }],
                "total": 60,
                "current_page": opts.page,
                "per_page": opts.per_page
            }
        })
    } else {
        return Mock.mock({
            "code": "0000",
            "message": "操作失败",
            "data": {
                "data": []
            }
        })
    }
});

export default {
    reconciliationMaterials
}